import {userInfo, IUserInfo,} from "./states"

interface UserAction {
    type: string,
    data?: IUserInfo| string, //清除的时候不需要传data
}

function userReducer(state = userInfo, action: UserAction) {
    switch (action.type) {

        case 'SET_USER_INFO':
            return {...state}

        case 'SET_TOKEN':
            return {...state, accessToken: action.data};

        case 'CLEAR_STORE':
            return {}

        default:
            return state;
    }

}

export default userReducer;
